//
//  ModelConfig.m
//  UEAssistant
//
//  Created by mac on 2017/10/25.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "ModelConfig.h"
#import "BaseModel.h"
#import <objc/runtime.h>

@implementation ModelConfig

+ (__kindof NSArray *_Nullable)modelWithObject:(id _Nullable )object modelClassString:(NSString * _Nullable)ClassString{
    
    NSArray *arr = (NSArray *)object;
    NSMutableArray *source = [NSMutableArray array];
    Class class = object_getClass(ClassString);
    if(class == nil) return source;
    if (![class isKindOfClass:[BaseModel class]]) return source;
    for (int i = 0; i < arr.count; i++) {
        NSDictionary *dic = arr[i];
        id model = [[class alloc]initWithDictionary:dic];
        [source addObject:model];
    }
    return source;
}


@end
